fix(web): 멘토 채팅 이미지 대기 상태 개선#522
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (5)
Walkthrough이 PR은 채팅 시스템의 이미지 첨부 처리를 체계적으로 개선하는 아키텍처 개선입니다:
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Suggested reviewers
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 inconclusive)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In
`@apps/web/src/app/mentor/chat/`[chatId]/_ui/ChatContent/_hooks/useChatListHandler.ts:
- Around line 159-165: When chatId changes the hook currently resets
prevChatIdRef, hasInitialAutoScrolledRef, and prevMessageCountRef but does not
clear preview state, causing leftover blob URLs and image mappings to leak into
memory and future rooms; inside the same useEffect that checks prevChatIdRef and
sets those refs, iterate objectUrlsRef.current and call URL.revokeObjectURL for
each stored URL then set objectUrlsRef.current = new Map() (or clear()) and set
imagePreviewByUrlRef.current = new Map() (or clear()) so both the blob URLs are
revoked and the preview mapping is emptied when chatId changes; reference the
useEffect in useChatListHandler.ts and the refs objectUrlsRef and
imagePreviewByUrlRef when applying this change.
In
`@apps/web/src/app/mentor/chat/`[chatId]/_ui/ChatContent/_ui/ChatMessageBox/index.tsx:
- Around line 74-80: The current logic flips setIsReady(true) and
setIsFailed(true) when attempt >= CHAT_IMAGE_HEALTH_CHECK_LIMIT, which forces
rendering of FallbackImage permanently and never re-probes CDN updates; change
this so that hitting the fast retry limit marks the fast probe as failed but
does NOT mark the message permanently ready. Instead, keep setIsReady(false) (or
clear the ready flag) and schedule a slower, longer-interval poll (or restart
checkImage on a longer timeout) so the background probe continues (e.g., after
CHAT_IMAGE_HEALTH_CHECK_LIMIT is reached use a slower interval or a separate
slow retry loop instead of terminating), and mirror the same change for the
analogous block around lines 105-119; reference functions/vars: checkImage,
CHAT_IMAGE_HEALTH_CHECK_LIMIT, CHAT_IMAGE_HEALTH_CHECK_INTERVAL_MS, setIsReady,
setIsFailed to locate and update the logic.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 090c020b-eb07-4d22-a415-f4461c0bd28a
📒 Files selected for processing (5)
apps/web/src/app/mentor/chat/[chatId]/_ui/ChatContent/_hooks/useChatListHandler.tsapps/web/src/app/mentor/chat/[chatId]/_ui/ChatContent/_ui/ChatMessageBox/index.tsxapps/web/src/app/mentor/chat/[chatId]/_ui/ChatContent/index.tsxapps/web/src/components/ui/FallbackImage.tsxapps/web/src/types/chat.ts
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 22edfcc0aa
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (!hasError && resolvedSrc !== fallbackSrc) { | ||
| setFailedSource(sourceKey); | ||
|
|
||
| if (canRetry) { | ||
| if (retryTimeoutRef.current) { | ||
| clearTimeout(retryTimeoutRef.current); | ||
| } | ||
|
|
||
| retryTimeoutRef.current = setTimeout(() => { | ||
| setRetryAttempt((prev) => prev + 1); | ||
| setFailedSource((current) => (current === sourceKey ? null : current)); | ||
| retryTimeoutRef.current = null; | ||
| }, normalizedRetryDelayMs); | ||
| } | ||
| } |
There was a problem hiding this comment.
Reset failed source when image src changes
After an image load error, failedSource is set and never cleared unless the component unmounts. Because hasError is derived from failedSource === sourceKey, returning to the same src later (e.g., transient CDN failure, then switching away and back) will immediately render fallback and never retry that URL in this component instance. The previous implementation reset failure state on source changes, so this is a regression in recoverability.
Useful? React with 👍 / 👎.
| const retryDelayMs = | ||
| attempt >= CHAT_IMAGE_HEALTH_CHECK_LIMIT | ||
| ? CHAT_IMAGE_HEALTH_CHECK_SLOW_INTERVAL_MS | ||
| : CHAT_IMAGE_HEALTH_CHECK_INTERVAL_MS; | ||
| timeoutId = setTimeout(checkImage, retryDelayMs); |
There was a problem hiding this comment.
Stop health-check polling after repeated image failures
The chat image health check schedules another checkImage on every onerror with no terminal condition, so a permanently invalid/forbidden URL will be requested indefinitely (every 5s after the limit). In long-lived chat sessions this creates unbounded background traffic and leaves the UI stuck on a spinner instead of falling back to a stable failure state.
Useful? React with 👍 / 👎.
Summary
Test
Notes